﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models.world.vos.areas {
    import flash.geom.*;
    import net.wooga.pets.interfaces.*;

    public class WaitingQueueVO extends RoomVO implements IWaitingQueue {

        private const PET_OFFSET_X:int = 275;
        private const INITIAL_X:int = 850;
        private const INITIAL_Y:int = 200;

        private var _waitingQueue:Array;

        public function WaitingQueueVO(_arg1:Object){
            this._waitingQueue = [];
            super(_arg1);
        }
        override public function getTargetPositionOf(_arg1:String, _arg2:Number=0):Point{
            var _local3:Point = new Point(this.INITIAL_X, this.INITIAL_Y);
            var _local4:int = this.getPositionInQueue(_arg1);
            _local3.x = (_local3.x + (this.PET_OFFSET_X * _local4));
            return (_local3);
        }
        override public function addActor(_arg1:IActing):void{
            super.addActor(_arg1);
            if ((_arg1 is IWaiting)){
                if (IWaiting(_arg1).queueIndex > 0){
                    this.waitingQueue.splice(IWaiting(_arg1).queueIndex, 0, _arg1);
                } else {
                    this.waitingQueue.push(_arg1);
                };
            };
        }
        override public function removeActor(_arg1:String):IActing{
            this.removeFromQueue(_arg1);
            return (super.removeActor(_arg1));
        }
        private function removeFromQueue(_arg1:String):void{
            var _local2:IActing;
            var _local3:int;
            while (_local3 < this.waitingQueue.length) {
                _local2 = this.waitingQueue[_local3];
                if (_local2.id == _arg1){
                    this.waitingQueue.splice(_local3, 1);
                    return;
                };
                _local3++;
            };
        }
        public function getPositionInQueue(_arg1:String):int{
            var _local2:IActing;
            var _local3:int;
            while (_local3 < this.waitingQueue.length) {
                _local2 = this.waitingQueue[_local3];
                if (_local2.id == _arg1){
                    return (_local3);
                };
                _local3++;
            };
            return (0);
        }
        public function get waitingQueue():Array{
            return (this._waitingQueue);
        }

    }
}//package net.wooga.pets.models.world.vos.areas 
